package com.leetcode.algorithm.y22.m07;

import com.leetcode.algorithm.common.ListNode;

/**
 * 141. 环形链表
 * 
 * https://leetcode.cn/problems/linked-list-cycle/
 * 
 * @author jie.deng
 *
 */
public class Question0141Solution01 {
	
	public boolean hasCycle(ListNode head) {
		ListNode fast = head;
		ListNode slow = head;
		while (fast != null && fast.next != null) {
			slow = slow.next;
			fast = fast.next.next;
			if (fast == slow) {
				return true;
			}
		}
		return false;
	}
    
}